<?php
/**
 * 员工
 * Created by PhpStorm.
 * User: echa
 * Date: 2018/3/7
 * Time: 15:46
 */
namespace App\Http\Controllers\WarehouseManage;
use App\Http\Controllers\ApiController;
use App\Services\Warehouse\EmployeesService;
use Illuminate\Http\Request;

class EmployeesController extends ApiController{

    protected $EmployeesService;
    public function __construct(EmployeesService $employeesService){
        $this->EmployeesService=$employeesService;
    }


    /**
    *  根据员工编号，获取该员工详情
     */
    public function GetEmployeesInfo(Request $request){
        $FStaffNumber=$request->employees_num;
        $info=$this->EmployeesService->DetailsEmployees($FStaffNumber);
        return $info;
    }

    /**
     * 创建员工
    */
    public function SaveEmployees(Request $request){
        $FName=$request->name;
        $FStaffNumber=$request->employees_num;
        $FMobile=$request->phone;
        $FPostDeptFNumber=$request->departments;
        $FPostFNumber=$request->salesman;
        $savedata=[
            'FName'=>$FName,
            'FStaffNumber'=>$FStaffNumber,
            'FMobile'=>$FMobile,
            'FPostDeptFNumber'=>$FPostDeptFNumber,
            'FPostFNumber'=>$FPostFNumber
        ];
        $data=$this->EmployeesService->SaveEmployees($savedata);
        return $data;
    }

    /**
    *   编辑员工
    */
    public function EditEmployees(Request $request){
        $FID=$request->fid;
        $FMobile=$request->phone;
        $FPostDeptFNumber=$request->departments;
        $FPostFNumber=$request->salesman;
        $savedata=[
            'FID'=>$FID,
            'FMobile'=>$FMobile,
            'FPostDeptFNumber'=>$FPostDeptFNumber,
            'FPostFNumber'=>$FPostFNumber
        ];
        $data=$this->EmployeesService->SaveEmployees($savedata);
        return $data;
    }
}